
function show(selector)
{
    $(selector).show();
}
function hide(selector)
{
    $(selector).hide();
}

function isValidEmail(email) {
    var reg = /^([a-zA-Z0-9]+[_|\_|\.]?)*[a-zA-Z0-9]+@([a-zA-Z0-9]+[_|\_|\.]?)*[a-zA-Z0-9]+\.[a-zA-Z]{2,3}$/;

    return reg.test(email);
}

function isNum(num) {
    var reg = /^\d+$/;
    return reg.test(num);

}

function isMobile(mobile) {

    var reg = /^\d{11}$/;
    return reg.test(mobile);

}

function isPositiveNum(num) {
    var reg = /^\d*.?\d+$/;
    return reg.test(num);

}
function isIDCard(idCard) {

    var reg = /^([0-9]{14}|[0-9]{17})(x|[0-9]){1}$/;
    return reg.test(idCard);

}
function showTip(id, content) {
    $("#" + id).empty();
    $("#" + id).append(content);
    show("#" + id);
}

function isElementExist(id) {
    return $("#" + id).length > 0 ? true : false;
}


function toURL(url) {
    window.location = url;
}

function getUrlParaValue(url, paras) {
    var paraString = url.substring(url.indexOf("?") + 1, url.length).split("&");
    var paraObj = {}
    for (i = 0; j = paraString[i]; i++) {
        paraObj[j.substring(0, j.indexOf("=")).toLowerCase()] = j.substring(j.indexOf("=") + 1, j.length);
    }
    var returnValue = paraObj[paras.toLowerCase()];
    if (typeof (returnValue) == "undefined") {
        return "";
    } else {
        return returnValue;
    }
}

function setCookie(name, value, expiredays) {

    var ExpireDate = new Date();
    ExpireDate.setTime(ExpireDate.getTime() + (expiredays * 24 * 3600 * 1000));

    document.cookie = name + "=" + escape(value) + ((expiredays == null) ? "" : "; expires=" + ExpireDate.toGMTString());
}


function getCookie(name) {

    if (document.cookie.length > 0) {

        begin = document.cookie.indexOf(name + "=");
        if (begin != -1) {

            begin += name.length + 1; 
            end = document.cookie.indexOf(";", begin); 
            if (end == -1) end = document.cookie.length; 
            return unescape(document.cookie.substring(begin, end));
        }
    }

    return null;
}

function delCookie(name) {

    if (getCookie(name)) {
        document.cookie = name + "=; expires=Thu, 01-Jan-70 00:00:01 GMT";
    }
}


function isVisible(id) {
    if (!isElementExist(id)) {
        return false;
    }
    if ($("#" + id).is(":visible")) {
        return true;
    }
    return false;
}

function clearContent(selector)
{
    $(selector).empty();
}

function showCover(width, height, isClose, content, title) {
    if (!title) {
        title = "Tip";
    }
    if (isElementExist("dialog_bg_tip")) {
        $("#dialog_bg_tip").remove();
    }
    var html = '';
    html += '<div id="dialog_bg_tip" style="display:none;">';
    html += '<div id="fullbg_dialog"></div>';
    if (isClose) {
        height += 20;
    }
    if (width > 0 && height > 0 && content != '') {
        html += '<div id="_dialog_container" style="width:' + width + 'px;height:' + height + 'px;position:absolute;background:white;display: none;z-index: 5;border:1px solid black;">';
        if (isClose) {
            html += '<div style="height:20px;text-align:right;border-bottom:double 1px gray;">';
            html += '<div style="float:left;width:70%;text-align:left;height:20px;"><span  style="margin-left:15px;" >'+title+'</span></div>';
            html += '<div style="float:left;width:30%;text-align:right;height:20px;"><span  style="cursor:pointer;margin-right:15px;color:red;" onclick="$(\'#dialog_bg_tip\').hide();">Close</span></div>';
            html+='</div>';
        }
        html += '<div>' + content + '</div>';
        html += '</div>';
    }
    html += '</div>';
    $("body").append(html);
    $("#dialog_bg_tip").show();

    var bH = $("body").height();
    var bW = $("body").width() + 16;

    var st = document.documentElement.scrollTop;
    var sl = document.documentElement.scrollLeft;
    var ch = document.documentElement.clientHeight;
    var cw = document.documentElement.clientWidth;
    var objH = $("#_dialog_container").height();
    var objW = $("#_dialog_container").width();
    var tbT = Number(st) + (Number(ch) - Number(objH)) / 2;
    var tbL = Number(sl) + (Number(cw) - Number(objW)) / 2;
    $("#fullbg_dialog").css({ width: bW, height: bH, display: "block" });
    $("#_dialog_container").css({ top: tbT + "px", left: tbL + "px", display: "block" });
}